/**
 * Filter Params - trieda na reprezentaciu a parsovanie filtrov
 * @author Tomas Srna
 * @package bakalarka
 */

function filterParams(str) {
	
	// Typy parametrov
	this.paramTypes = new Array();
	
	// Parsovanie zo stringu
	this.load = function(str) {
		if(str == undefined)
			return;
		var param, value;
		var i, toVal = false;
		param = "";
		value = "";
		for(i = 0; i < str.length; ++i) {
			if(str.charAt(i) == '[' || str.charAt(i) == ']')
				continue;
			if(str.charAt(i) == ':')
				toVal = !toVal;
			else if(str.charAt(i) == ';') {
				toVal = false;
				eval("this."+param+"=\""+value+"\"");
				this.paramTypes.push(param);
				param = "";
				value = "";
			} else {
				if(!toVal)
					param += str.charAt(i);
				else
					value += str.charAt(i);
			}
		}
		if(param != "" && value != "") {
			eval("this."+param+"=\""+value+"\"");
			this.paramTypes.push(param);
		}
	};
	
	// Konstruktor vola load
	this.load(str);
	
	// Synteza stringu z parametrov
	this.get = function() {
		var result = Array();
		for(var param in this.paramTypes) {
			var value = eval("this."+this.paramTypes[param]);
			if(value != undefined)
				result.push(this.paramTypes[param] + ":" + value);
		}
		return '['+result.join(";")+']';
	};
	
	// Kopirovanie
	this.copy = function(from) {
		for(var param in from.paramTypes) {
			eval("this."+this.paramTypes[param]+"=from."+this.paramTypes[param]);
			this.paramTypes.push(param);
		}
	};
	
}
